#include "common.h"

int findPoisonedDuration(vector<int>& times, int duration)
{
	int ans = 0;
	int end = times[0] + duration - 1;
	for (int i = 1; i < times.size(); i++)
	{
		if (times[i] <= end) ans += times[i] - times[i - 1];
		else ans += duration;
		end = times[i] + duration - 1;
	}
	ans += duration;
	return ans;
}
